/*
 * PACKAGE NAME: com.jodinfo.outmirror.api.reportaccessstorage.controller
 * FILE    NAME: ReportAccessStorageDaoImpl.java
 * COPYRIGHT: Copyright(c) © 2016 heroj Company Ltd. All Rights Reserved
 */ 
package com.jodinfo.outmirror.api.reportaccessstorage.controller;

import java.math.BigInteger;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.alibaba.fastjson.JSON;
import com.hero.common.web.context.UserContext;
import com.hero.core.constant.SysConstant;
import com.hero.core.entity.IPlatformUser;
import com.hero.core.entity.ResponseEntity;
import com.jodinfo.outmirror.api.reportaccessstorage.entity.ReportAccessStorageEntity;
import com.jodinfo.outmirror.api.reportaccessstorage.service.ReportAccessStorageBizService;



@Controller
@RequestMapping(value = "/ReportAccessStorageAdmin")
public class ReportAccessStorageController  {
	
@Resource(name="reportAccessStorageBizService")
private ReportAccessStorageBizService ReportAccessStorageBizService;
/**
*  list数据源
* 
* */
@RequestMapping(value = "/List")
@ResponseBody
public String ReportAccessStorageList(ReportAccessStorageEntity ReportAccessStorageEntity) {
	if(ReportAccessStorageEntity==null){
		ReportAccessStorageEntity = new ReportAccessStorageEntity();
		ReportAccessStorageEntity.setPageIndex(SysConstant.DEFAULT_PAGEINDEX);
		ReportAccessStorageEntity.setPageSize(SysConstant.DEFAULT_PAGESIZE);
	}
	ReportAccessStorageEntity.setCurrentUser(UserContext.getUser());
	if(StringUtils.isEmpty(ReportAccessStorageEntity.getBranchOrgId()) && StringUtils.isEmpty(ReportAccessStorageEntity.getOfficeOrgId())){
		ReportAccessStorageEntity.setBranchOrgId(((IPlatformUser)UserContext.getUser()).getOrgId());
		ReportAccessStorageEntity.setOfficeOrgId(((IPlatformUser)UserContext.getUser()).getOrgId());	
	}
	String str = ReportAccessStorageBizService.queryListForPageReportAccessStorage(ReportAccessStorageEntity);
	return str;
}
/**
* ReportAccessStorageEntity List页面
* 
* */
@RequestMapping(value = "/ListPage")
public ModelAndView ReportAccessStorageListPage(ReportAccessStorageEntity ReportAccessStorageEntity,HttpServletRequest request) {
	
	return new ModelAndView(returnPath("ReportAccessStorageList"));
}
/**
* ReportAccessStorageEntity详细页 
* 
* */
@RequestMapping(value = "/EditPage")
public ModelAndView ReportAccessStorageEditPage(ReportAccessStorageEntity ReportAccessStorageEntity) {
	
	return new ModelAndView(returnPath("ReportAccessStorageAdd"));
}
/**
 * 查询ReportAccessStorageEntity
 * 
 * */
@RequestMapping(value = "/queryByID")
public @ResponseBody String findReportAccessStorageData(HttpServletRequest request) {
	String id = request.getParameter("id");
	ReportAccessStorageEntity ReportAccessStorageEntity =  ReportAccessStorageBizService.queryById(new BigInteger(id));
	return JSON.toJSONString(ReportAccessStorageEntity); 
}

/**
 * 保存或更新ReportAccessStorage 
 * 
 * */
@RequestMapping(value = "/saveReportAccessStorage")
public @ResponseBody String saveReportAccessStorageData(@RequestBody ReportAccessStorageEntity ReportAccessStorageEntity) {
	ResponseEntity rs = null;
	if(ReportAccessStorageEntity!=null){
		ReportAccessStorageEntity.setCurrentUser(UserContext.getUser());
		if(ReportAccessStorageEntity.getId()!=null){
			rs = ReportAccessStorageBizService.updateReportAccessStorage(ReportAccessStorageEntity);
		}else{
			rs = ReportAccessStorageBizService.addReportAccessStorage(ReportAccessStorageEntity);
		}
	}
	return JSON.toJSONString(rs);
}
/**
 * 导出ReportAccessStorageEntity
 * @author weiwei
 * @date 2015-7-09  下午2:13:28
 * @return
 */
@RequestMapping(value = "/exportReportAccessStorageExcel")
public void exportReportAccessStorageExcel(ReportAccessStorageEntity ReportAccessStorageEntity,HttpServletResponse response) {
	if(ReportAccessStorageEntity==null) ReportAccessStorageEntity = new ReportAccessStorageEntity();
	ReportAccessStorageEntity.setCurrentUser(UserContext.getUser());
	if(StringUtils.isEmpty(ReportAccessStorageEntity.getBranchOrgId()) && StringUtils.isEmpty(ReportAccessStorageEntity.getOfficeOrgId())){
		ReportAccessStorageEntity.setBranchOrgId(((IPlatformUser)UserContext.getUser()).getOrgId());
		ReportAccessStorageEntity.setOfficeOrgId(((IPlatformUser)UserContext.getUser()).getOrgId());	
	}
	ReportAccessStorageBizService.exportReportAccessStorage(ReportAccessStorageEntity, response);
}


 /**
 * 
 * 批量删除
 * @author weiwei
 * @date 2017年3月13日 下午2:48:57
 * @param ReportAccessStorageEntity
 * @return
 */
@RequestMapping(value = "/batchDelReportAccessStorage")
public @ResponseBody String batchDelReportAccessStorage(ReportAccessStorageEntity ReportAccessStorageEntity) {
	ResponseEntity rs = null;
	rs = ReportAccessStorageBizService.batchDelReportAccessStorage(ReportAccessStorageEntity);
	return  JSON.toJSONString(rs);
}
/**
 * 定义
 * 
 */
private final String MODULE_PATH = "/reportaccessstorage/";

//返回路径
private String returnPath(String jspName) {
	return MODULE_PATH + jspName;
}
}
